//
//  XJVisitorViewController.swift
//  XJWeiBO
//
//  Created by 452608533 on 16/7/19.
//  Copyright © 2016年 452608533. All rights reserved.
//

import UIKit

class XJVisitorViewController: UIViewController {

    //判断是否登录
    
    var isLogin: Bool = XJUserAccountViewModel.sharedTools.isLogin
    //访客视图
    var visitorView: XJVisitorView?
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    

    override func loadView() {
        
        isLogin ? (view = tableView) :setupVisitorView()
    }
    
    func setupVisitorView() {
        
        visitorView = XJVisitorView()
        visitorView?.closure = {[weak self] in
            self?.clickNavItem()
        }
        view = visitorView
        
        setupNav()
    }
    
    func setupNav() {
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", imgName: nil, target: self, action: "clickNavItem")
        navigationItem.rightBarButtonItem = XJBarButtonItem(title: "注册", imgName: nil, target: self, action: "clickNavItem")
    }
    @objc private func clickNavItem() {
    let auothV = XJAuthViewController()
        presentViewController(UINavigationController(rootViewController: auothV), animated: true, completion: nil)
    }
    //懒加载控件
    
    lazy var tableView: UITableView = UITableView()

}
